import request from './request'

interface UserQueryParams {
  current?: number;
  size?: number;
  username?: string;
  nickname?: string;
  phone?: string;
  startDate?: string;
  endDate?: string;
}

// 获取用户列表（分页）
export function getUserList(params: UserQueryParams) {
  return request({
    url: '/user/page',
    method: 'get',
    params
  })
}

// 根据部门ID获取用户列表
export function getUsersByDeptId(deptId: number) {
  return request({
    url: `/user/dept/${deptId}`,
    method: 'get'
  })
}

// 获取用户详情
export function getUserById(id: number) {
  return request({
    url: `/user/${id}`,
    method: 'get'
  })
}

// 添加用户
export function addUser(data: any) {
  return request({
    url: '/user',
    method: 'post',
    data
  })
}

// 更新用户
export function updateUser(data: any) {
  return request({
    url: '/user',
    method: 'put',
    data
  })
}

// 删除用户
export function deleteUser(id: number) {
  return request({
    url: `/user/${id}`,
    method: 'delete'
  })
}

// 重置用户密码
export function resetPassword(id: number) {
  return request({
    url: `/user/resetPassword/${id}`,
    method: 'put'
  })
}

// 修改用户状态
export function updateUserStatus(id: number, status: number) {
  return request({
    url: `/user/status/${id}/${status}`,
    method: 'put'
  })
}

// 分配用户角色
export function assignRoles(userId: number, roleIds: number[]) {
  return request({
    url: `/user/assignRoles/${userId}`,
    method: 'put',
    data: roleIds
  })
}

// 获取用户角色ID列表
export function getUserRoleIds(userId: number) {
  return request({
    url: `/user/roleIds/${userId}`,
    method: 'get'
  })
} 